#include<stdio.h>
#include<math.h>
int shuixianhua(int number){
	int count=0,n=number,i,sum=0;
	while(n){
		n/=10;
		count++;
	} 
	n=number;
	while(n){
		i=n%10;
		sum=sum+pow(i,count);
		n=n/10;
	}
	if(sum==number)
		return 1;
	else
		return 0;
}
int main(){
	int number;
	scanf("%d",&number);
	if(shuixianhua(number))
	printf("%d",number);
	return 0;
} 
